import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.print("请输入第一个数字: ");
        double num1 = scanner.nextDouble();
        
        System.out.print("请输入第二个数字: ");
        double num2 = scanner.nextDouble();
        
        System.out.print("请输入操作符 (+, -, *, /): ");
        char operator = scanner.next().charAt(0);

        scanner.close();    // 关闭 Scanner 对象

        
        double result;
        switch (operator) {
            case '+':
                result = num1 + num2;
                break;
            case '-':
                result = num1 - num2;
                break;
            case '*':
                result = num1 * num2;
                break;
            case '/':
                if (num2 != 0) {
                    result = num1 / num2;
                } else {
                    System.out.println("错误: 除数不能为零");
                    return;
                }
                break;
            default:
                System.out.println("错误: 无效的操作符");
                return;
        }
        System.out.printf("结果: %.2f %c %.2f = %.2f\n", num1, operator, num2, result);

    }
}

//在终端中使用以下命令编译和运行： javac Calculator.java  java Calculator